package xyz.scootaloo.mono.data.db

import org.apache.catalina.connector.Connector
import org.apache.catalina.connector.Request
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
import xyz.scootaloo.mono.base.lang.TestDsl
import xyz.scootaloo.mono.data.DataModuleBootStrap
import xyz.scootaloo.mono.data.entity.auth.AuthRole
import xyz.scootaloo.mono.data.service.AuthService

/**
 * @author flutterdash@qq.com
 * @since 2021/8/4 13:03
 */
@RunWith(SpringRunner::class)
@SpringBootTest(classes = [DataModuleBootStrap::class])
class InsertRoleRecord : TestDsl {

    @Autowired lateinit var authService: AuthService

    @Test
    fun insertRecord() {
        val request = Request(Connector())
        getRecords().forEach {
            authService.addAuthRole(request, it)
        }
    }

    private fun getRecords(): List<AuthRole> {
        return listOf(
            AuthRole.edit {
                code = 1
                name = "guest"
                desc = "访客角色"
            },
            AuthRole.edit {
                code = 2
                name = "user"
                desc = "用户角色"
            },
            AuthRole.edit {
                code = 4
                name = "vip"
                desc = "会员用户"
            },
            AuthRole.edit {
                code = 8
                name = "admin"
                desc = "后台管理员"
            },
            AuthRole.edit {
                code = 16
                name = "sys_admin"
                desc = "系统管理员"
            }
        )
    }

}
